#include <stdio.h>

#define HEAP_SIZE 100009

int heap[HEAP_SIZE];

int top;

void sift_up()
{
    int i = top - 1;
    int tmp;
    while(i != 0)
    {
        if(heap[i] > heap[(i - 1) / 2])
        {
            tmp = heap[i];
            heap[i] = heap[(i - 1) / 2];
            heap[(i - 1) / 2] = tmp;
            i = (i - 1) / 2;
        }
        else
            break;
    }
}

void sift_down()
{
    int i = 0;
    int tmp;
    int a;
    while(2 * i + 1 < top)
    {
        if(2 * i + 2 < top)  // ���� ������ ���
        {
             if((heap[i] < heap[2 * i + 1]) ||  (heap[i]  < heap[2 * i + 2]))
             {
                if(heap[2 * i + 1] > heap[2 * i + 2])
                {
                    tmp = heap[i];
                    heap[i] = heap[2 * i + 1];
                    heap[2 * i + 1] = tmp;
                    i = (2 * i + 1);
                }
                else
                {
                    tmp = heap[i];
                    heap[i] = heap[2 * i + 2];
                    heap[2 * i + 2] = tmp;
                    i = (2 * i + 2);
                }
             }
             else
                 break;
        }
        else  //��� ������� ����
        {
            if(heap[i] < heap[2 * i + 1])
            {
                tmp = heap[i];
                heap[i] = heap[2 * i + 1];
                heap[2 * i + 1] = tmp;
                break;
            }
            else
            {
                break;
            }
        }
    }
}


void add(int x)
{
    heap[top] = x;
    top++;
    sift_up();
}

int extract()
{
    int tmp;
    tmp = heap[0];
    heap[0] = heap[top - 1];
    top--;
    sift_down();
    return tmp;

}


int main()
{
    int n, i, a;
    int b;
    top = 0;
    scanf("%i", &n);
    for(i = 0; i < n; i++)
    {
        scanf("%i", &a);
        add(a);

    }
    for(i = 0; i < n; i++)
    {
        printf("%i", extract(a));
        printf("%i", extract(a)):
    }

}
